<template>
  <div class="e-table">
    <div class="top">
      <el-form ref="form" :model="formData" label-width="160px" :rules="rules">
        <el-row>
          <el-col :span="6">
            <el-form-item label="结算单位：">
              <el-select placeholder="请选择">
                <el-option> </el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="类型：">
              <el-select placeholder="请选择">
                <el-option> </el-option>
              </el-select> </el-form-item
          ></el-col>
          <el-col :span="6">
            <el-form-item label="源单编号：">
              <el-select placeholder="请选择">
                <el-option> </el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="本位币：">
              <el-input
                placeholder="请输入内容"
                v-model="input3"
                class="input-with-select"
              >
                <el-button slot="append" icon="el-icon-search"></el-button>
              </el-input>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
    </div>
    <el-table
      class="table"
      :data="tableData"
      border
      style="width: 100%"
      :cell-class-name="cellClsNm"
      :height="tableHeight"
    >
      <el-table-column type="selection" width="55" fixed> </el-table-column>
      <el-table-column
        label="入库编号"
        min-width="200"
        show-overflow-tooltip
        class-name="blue-column"
        fixed
      >
        <template slot-scope="{ row }">
          <span @click="tableDbShow(row)">{{ row.settleNo }}</span>
        </template>
      </el-table-column>
      <el-table-column prop="settleDate" label="合同编号" width="150">
      </el-table-column>
      <el-table-column
        prop="orgName"
        label="物资名称"
        align="right"
        width="150"
      >
      </el-table-column>

      <el-table-column
        prop="settleOrg"
        label="规格"
        align="right"
        min-width="150"
      >
      </el-table-column>
      <el-table-column
        prop="amountExcludingTax"
        label="材质"
        align="right"
        width="180"
      >
      </el-table-column>
      <el-table-column
        prop="totalTaxPrice"
        label="单位"
        align="right"
        width="150"
      >
      </el-table-column>
      <el-table-column
        prop="cumulativeSettleAmount"
        label="仓库"
        align="right"
        width="180"
      >
      </el-table-column>
      <el-table-column
        prop="settleType"
        label="验收数量"
        align="right"
         width="150"
      >
      </el-table-column>
      <el-table-column
        prop="totalCost"
        label="已结算数量"
        align="right"
        width="150"
      >
      </el-table-column>
      <el-table-column
        prop="sourceNo"
        label="未结算数量"
        align="right"
        width="150"
      >
      </el-table-column>

      <el-table-column
        prop="sourceNo"
        label="验收单价（元）"
        align="right"
        width="150"
      >
      </el-table-column>
      <el-table-column
        prop="sourceNo"
        label="验收金额（元）"
        align="right"
        width="150"
      >
      </el-table-column>
    </el-table>
    <ComPagination
      :total="totalPage"
      :pageSize.sync="pagination.limit"
      :currentPage.sync="pagination.page"
      @currentChange="listByEntity"
      @sizeChange="listByEntity"
      class="bottomSetting"
    />
    <!-- mask -->
    <elDialog
      :dialogVisibleSearch="dialogVisibleSearch"
      @heightSharchClose="heightSharchClose"
      @heightSharch="heightSharch"
    />
  </div>
</template>

<script>
import request from '@/api/PCCset/apply.js'
import ComPagination from '@/components/pagination/pagination.vue'
import elDialog from '@/pages/equipment/equipPlan/commonSearch/elDialog.vue'
import { vueDom, debounce } from '@/utils/common.js'
import { getCurrentUnitInfo } from '@/api/equip/common.js'
export default {
    data () {
        return {
            formData: {},
            isAttention: true,
            tableData: [],
            loading: false,
            MouseEnterId: 0,
            buySettleDTO: '',
            dialogVisibleSearch: false,
            pagination: {
                endTime: '',
                limit: 1,
                organization: '',
                page: 1,
                query: '',
                settleUnit: '',
                startTime: '',
                status: [],
            },
            totalPage: 0, //总页数
            tableHeight: 0,
            auditState: {}, //流程按钮显示状态
            auditParams: {
                billId: '',
                billType: 5012, //租赁计划
                freeNextUnitIndex: null,
                freeNextUser: '',
                isPass: true,
                isShareInAudit: true,
                opinion: '',
                orgId: '',
                orgName: '',
                userId: '',
                workId: '',
            },
        }
    },
    components: {
        ComPagination,
        elDialog,
    },
    computed: {},
    created () {
        this.getList()
    },
    mounted () {
    // table动态高度
        vueDom(
            () => {
                this.tableHeight = document.body.clientHeight - 240
            },
            () => {
                return $('table').length !== 0
            }
        )
        this.fn = () => {
            this.tableHeight = document.body.clientHeight - 240
        }
        window.onresize = debounce(this.fn)
    },
    methods: {
    //获取列表
        getList () {
            request.PccSetListInfo(this.pagination).then(res => {
                this.tableData = res.list
                this.totalPage = res.totalCount
            })
        },
        //获取流程按钮显示状态
        getCurrentUnitInfo () {
            getCurrentUnitInfo(this.auditParams).then(res => {
                this.auditState = res
            })
        },
        //分页查询
        listByEntity () {
            this.getList()
        },
        //新增
        openAddDialog () {
            this.$router.push('/NewPlanAdd')
        },
        //查看
        tableDbShow (row) {
            if (row.state === -1 || row.state === 2 || row.state === 5) {
                this.$router.push({
                    path: '/leasePlanShow',
                    query: { billid: row.billId },
                })
            } else {
                this.auditParams.billId = row.billId
                getCurrentUnitInfo(this.auditParams).then(res => {
                    this.auditState = res
                    if (this.auditState.canModify == true) {
                        this.$router.push({
                            path: '/leasePlanEdit',
                            query: { billid: row.billId },
                        })
                    } else {
                        this.$router.push({
                            path: '/leasePlanShow',
                            query: { billid: row.billId },
                        })
                    }
                })
            }
        },
        //模糊搜索
        search () {
            this.getList()
        },
        // 高级搜索关闭
        heightSharchClose () {
            this.dialogVisibleSearch = false
        },
        //高级搜索
        heightSharch (val) {
            this.pagination = val
            this.getList()
        },
    },
}
</script>

<style lang="scss" scoped>
.e-table {
  min-height: 97.3vh;
}
::v-deep.el-steps--simple {
  background: #eff2f6;
  margin-bottom: 10px;
}
.dialog-footer {
  text-align: right;
}
</style>
